#include "GfxDriver/VertexElement.h"

namespace Orca {

	//--------------------------------------------------------------------------
	VertexElement::VertexElement(
		  VertexElementUsage inUsage
		, uint32 inFormat
		, uint32 inIndex) 
	
		: usage(inUsage)
		, format(inFormat)
		, index(inIndex) {

	}

	//--------------------------------------------------------------------------
	uint32 VertexElement::getElementSize(uint32 format) {

		VertexElementDataType dataType = 
			(VertexElementDataType)(format & 0x0000ffff);

		VertexElementDataCnt dataCnt = 
			(VertexElementDataCnt)((format & 0xffff0000) >> 16);

		switch(dataType) {

			case VEDT_FLOAT:	return dataCnt << 2;
			case VEDT_BYTE:		return dataCnt;
			case VEDT_UBYTE:	return dataCnt;
			case VEDT_SHORT:	return dataCnt << 1;
			case VEDT_USHORT:	return dataCnt << 1;
			case VEDT_INT:		return dataCnt << 2;
			case VEDT_UINT:		return dataCnt << 2;
			case VEDT_RGBA:		return 4;
		};

		return 0;
	}

	//--------------------------------------------------------------------------
}